<?php
/**
 * Created by PhpStorm.
 * User: Zhoujinda
 * Date: 2016/3/26
 * Time: 10:47
 */

namespace Api\Domain;

use Bbs\Api\CoreReportApi;

class CoreReportDomain extends BaseDomain{

    protected $business_code = "coreReport";

    protected $allowType = array("json", "rss", "html");

    public function bbsReport(){

        if(IS_POST){
            $this->checkVersion(100);
            addLog("CoreReport/bbsReport",$_GET,$_POST,"应用" . $this->client_id . "调用论坛举报接口");

            $fid = $this->_post('fid','','论坛ID缺失');
            $tid = $this->_post('tid','','主题ID缺失');
            $pid = $this->_post('pid','','帖子ID缺失');
            $uid = $this->_post('uid','','被举报ID缺失');
            $username = $this->_post('username','','被举报用户名缺失');
            $op_uid = $this->_post('op_uid','','举报人ID缺失');

            $url = "http://testReport&".'fid='.$fid.'tid'.$tid.'pid'.$pid.'uid'.$uid.'op_uid'.$uid;
            $entity = array(
                'urlkey' => md5($url),
                'url' => $url,
                'message' => '论坛举报',
                'uid'=>$uid,
                'username' => $username,
                'op_uid' => $op_uid,
                'op_name' => '',
                'op_time' => 0,
                'op_result' =>'',
                'fid' => $fid,
            );

            $result = apiCall(CoreReportApi::ADD,array($entity));
            if($result['status']){
                $this->apiReturnSuc('举报成功!');
            }else{
                if($result['info']=='不能重复举报！'){
                    $this->apiReturnSuc('举报成功!');
                }else{
                    $this->apiReturnErr($result['info']);
                }

            }

        }else{
            $this->apiReturnErr('只支持POST请求');
        }

    }

}